package org.siamnet.java.examples.collections;

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;

public class CollectionsStudy {
	public static void main(String[] args) {
		// Example 001 - Basic Map, Set, Iterator while(){} loop.
		Map<String, String> map = new HashMap<String, String>();
		map.put("cat1", "Siam");
		map.put("cat2", "Gabe");
		map.put("cat3", "Gizmo");
		map.put("cat4", "Keiko");
		map.put("cat5", "Milly");
		map.put("cat6", "Mozart");
		map.put("cat7", "Herberdal");
		map.put("cat8", "Tyger");
		map.put("cat9", "Bierje");
		map.put("cat10", "Jerry");
		Set set = map.entrySet();
		Iterator iterator = set.iterator();
		while ( iterator.hasNext() ) {
			Map.Entry<String, String> mapEntry = (Map.Entry) iterator.next();
			String key = (String) mapEntry.getKey();
			String value = (String) mapEntry.getValue();
			System.out.println("Example 001: key = " + key + " value = " + value);
		}
		
		// Example 002 - LinkedHashMap
		LinkedHashMap<Integer, String> linked = new LinkedHashMap<Integer, String>();
		linked.put(0, "This is the 0th value.");
		linked.put(1, "This is the 1th value.");
		linked.put(2, "This is the 2th value.");
		linked.put(3, "This is the 3th value.");
	}
}
